﻿using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DingApi.Models;
using System.Data;

using System.Web;
using Dingding.Helper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NCommon;

using System;
using System.Collections.Generic;
using System.ComponentModel;
 
using System.Drawing;
using System.Drawing.Printing;
 
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data.OleDb;
using System.Configuration;

using System.IO; 
 

namespace DingApi.Controllers
{
    [RoutePrefix("api/Products")]
    public class ProductsController : ApiController
    {
        [HttpPost]
        [Route("ProductsT")]
         

        //多记录查询
        public JObject PostProductsT([FromBody]  JObject obj)
        {

            return obj;


        }
          
        [HttpPost]
         [Route("UploadImage")]
        public string PostUploadImage(HttpPostedFileWrapper file, string userID)
        {

            MyFft ftp = new MyFft("_PADB/");

            return "sss";


            //var msg = bll.UploadImage(file.InputStream, userID);
            // var result = new ReturnResult<string>(msg);
            //return result.Serialize();
        }


         #region 测试微信小程序图片上传
         [Route("uploadfile")] //设置路由
         [HttpPost]
         public HttpResponseMessage WxPostFile()
         {
             ////定义
             //ResponseResult obj = new ResponseResult();
             //try
             //{
             //    HttpPostedFile file = HttpContext.Current.Request.Files[0];
             //    var userId = HttpContext.Current.Request["userId"];
             //    var path = "/upload/";
             //    var mapPath = HttpContext.Current.Server.MapPath(path); //硬盘物理目录
             //    var fileName = Until.GetNowTimeString();
             //    var fileExt = Path.GetExtension(file.FileName);
             //    var mapPathFullPath = mapPath + fileName + fileExt; //硬盘物理路径
             //    var siteFullPath = path + fileName + fileExt; //网站路径
             //    if (!Directory.Exists(mapPath))
             //    {
             //        Directory.CreateDirectory(mapPath);
             //    }
             //    file.SaveAs(mapPathFullPath);
             //    obj.status = true;
             //    obj.message = siteFullPath;
             //    obj.info = userId;
             //}
             //catch (Exception ex)
             //{
             //    obj.status = false;
             //    obj.message = ex.Message;
             //}
             //var resultObj = JsonConvert.SerializeObject(obj);
             HttpResponseMessage result = new HttpResponseMessage
             {
                // Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json")
             };
             return result;
         }
         #endregion




    }
}